from app.model.table_shop_address import TableShopAddress
from libs.db import DB


def get_shop(shop_id, fields=None):
    if fields is None:
        fields = ['id']
    try:
        shop = TableShopAddress.objects.filter(id=shop_id).values(*fields).get()
    except TableShopAddress.DoesNotExist:
        shop = {}
    return shop


def get_shop_by_id(cursor, shop_id, fields=None):
    if fields is None:
        fields = ['id', 'shop_name']
    db = DB('table_shop_address', conn=cursor)
    return db.one(fields, {'id': shop_id})
